import { defineStore } from 'pinia';
import { ref } from 'vue';
import { MedicalDocument } from '../types/medicalTypes';

interface Template {
  id: string;
  name: string;
  content: MedicalDocument;
}

interface TemplateState {
  templates: Template[];
  currentTemplate: Template | null;
  getAllTemplates: () => Template[];
}

export const useTemplateStore = defineStore('template', {
  state: (): TemplateState => ({
    templates: [],
    currentTemplate: null,
    getAllTemplates: function() {
      return this.templates;
    },
  }),
  
  actions: {
    setConfig(config: { templates: Template[] }) {
      this.templates = config.templates;
    },
    
    loadTemplate(templateId: string) {
      this.currentTemplate = this.templates.find(t => t.id === templateId) || null;
    }
  }
});